<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('标准仓库列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse" >
                <div class="form-group" style="float: right;">
                    <label class="checkbox-inline check-box">
                        <input type="hidden" name="templateId" th:value="${templateId}" id="templateId">
                        <input type="text" class="form-control" style="width: 230px" placeholder="按ENTER键执行搜索" id="filter" />
                    </label>
                </div>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('etl:dw:edit')}]];
        var removeFlag = [[${@permission.hasPermi('etl:dw:remove')}]];
        var prefix = ctx + "base/job/template/task";
        function submitHandler() {
            var idTemplate = $("#templateId").val();
            var rows = $("#bootstrap-table").bootstrapTable('getSelections');
            if(rows.length==0) {
                $.modal.alertError("需至少选择一条记录");
                return;
            }
            var data=[];
            $.each(rows,function (index,item) {
                data.push({"idFk":item.idDw,"idTemplate":idTemplate,"euType":"dw"});
            });
            $.ajax({
                url: prefix+"/addBatch",
                cache: false,
                async: false,
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(data),
                contentType: 'application/json;charset=UTF-8',
                success: function (result) {
                    if(result.code=="0") {
                        $.modal.alertSuccess("添加成功记得刷新表格");
                        $.modal.close();
                    }
                }
            });
        }
        $(function() {
            var options = {
                url: prefix + "/dw/list?templateId="+$("#templateId").val(),
                modalName: "标准仓库",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'idDw',
                    title: '',
                    visible: false
                },
                {
                    field: 'cdTb',
                    title: '表名'
                },
                {
                    field: 'na',
                    title: '表描述'
                },
                {
                    field: 'fgAct',
                    title: '启用标志'
                },
                {
                    field: 'dtSysCre',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.idDw + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idDw + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>